package moo.stargalaxy_bukkit.listener;

import moo.stargalaxy_bukkit.api.GalaxyBukkitAPI;
import moo.stargalaxy_bukkit.data.BukkitStarGalaxyData;
import moo.stargalaxy_bukkit.utils.CommandUtil;
import org.bukkit.event.EventHandler;
import org.bukkit.event.Listener;
import org.bukkit.event.player.AsyncPlayerChatEvent;
import org.bukkit.event.player.PlayerJoinEvent;
import org.bukkit.event.player.PlayerQuitEvent;

public class GalaxyListener implements Listener {
    // 监听进服处理操作
    @EventHandler
    public void join(PlayerJoinEvent event){
        GalaxyBukkitAPI.checkJoin(event.getPlayer());
    }
    // 监听退出处理操作
    @EventHandler
    public void quit(PlayerQuitEvent event){
        GalaxyBukkitAPI.checkQuit(event.getPlayer());
    }
    // 监听别名等聊天输出处理
    @EventHandler
    public void chat(AsyncPlayerChatEvent event){
        if(BukkitStarGalaxyData.getQuickCmd().containsKey(event.getMessage())){
            event.setCancelled(true);
            CommandUtil.executeCommand(event.getPlayer(), BukkitStarGalaxyData.getQuickCmd().get(event.getMessage()));
        }
    }
}

